package mysql8学习.初级.第09章_子查询;

/**
 *#子查询的编写技巧（或步骤）：① 从里往外写  ② 从外往里写
 *
 * 单行子查询
 *  单行操作符： =  !=  >   >=  <  <=
 *
 *  如果  子查询出来的没有值   就相当于NULL
 *
 * #题目：查询与141号员工的manager_id和department_id相同的其他员工
 * #的employee_id，manager_id，department_id。
 * #方式1：
 * SELECT employee_id,manager_id,department_id
 * FROM employees
 * WHERE manager_id = (
 * 		                 SELECT manager_id
 * 		                 FROM employees
 * 		                 WHERE employee_id = 141
 * 		                )
 * AND department_id = (
 * 		                 SELECT department_id
 * 		                 FROM employees
 * 		                 WHERE employee_id = 141
 * 		                )
 * AND employee_id <> 141;
 *
 *
 * #方式2：了解
 * SELECT employee_id,manager_id,department_id
 * FROM employees
 * WHERE (manager_id,department_id) = (
 *                                      SELECT manager_id,department_id
 *                                      FROM employees
 *                                      WHERE employee_id = 141
 *                                      )
 * AND employee_id <> 141;
 *
 *
 *
 *  #题目：查询最低工资大于110号部门最低工资的部门id和其最低工资
 *
 *  SELECT department_id,MIN(salary)
 *  FROM employees
 *  WHERE department_id IS NOT NULL
 *  GROUP BY department_id
 *  HAVING MIN(salary) > (
 *                      SELECT MIN(salary)
 *                      FROM employees
 *                      WHERE department_id = 110
 *                      );
 *
 */
public class C_单行子查询 {
    public static void main(String[] args) {

    }
}
